import { chemical_server as request } from '@/service'

interface ResultType {
  result: {
    resultCode: string
    resultMessage: string
  }
  data: object
}

/** 适配接口返回结果 */
function adapter(response: ResultType) {
  if (response.result.resultCode == '000000') {
    return response.data
  }
  throw new Error()
}

// 出入口新增
export const upDatcrk = (params?: any) =>
  request.post(`/crkxx/insertOrUpdate`, params).then((res) => adapter(res as any))
// 出入口新增
export const upDatsgcxz = (params?: any) =>
  request.post(`/yjsgcxx/insertOrUpdate`, params).then((res) => adapter(res as any))
// 限宽新增
export const upDatxk = (params?: any) =>
  request.post(`/dl/insertOrUpdate`, params).then((res) => adapter(res as any))
// 地势新增
export const upDatds = (params?: any) =>
  request.post(`/dsgxx/insertOrUpdate`, params).then((res) => adapter(res as any))
// DCS新增
export const upDatdcs = (params?: any) =>
  request
    .post(
      `
/dcskzsxx/insertOrUpdate`,
      params
    )
    .then((res) => adapter(res as any))
// DCS新增
export const upDatxfkzs = (params?: any) =>
  request
    .post(
      `
/xfkzsxx/insertOrUpdate`,
      params
    )
    .then((res) => adapter(res as any))
//获取监控视频数据
export const queryHgspInfoList = (params?: any) =>
  request
    .get(
      `
hgsp/queryHgspInfoList`,
      { params }
    )
    .then((res) => adapter(res as any))
